package Decorator;

import Decorator.cashier.*;
import Decorator.constants.CasherEnum;
import javafx.css.CssMetaData;

/**
 * @author duanzhizhou
 * @date 2024/9/25
 */
public class CashContext {
    
    private Cashier cashier;
    
    public CashContext(CasherEnum casherEnum) {
        Cashier cashier = new NormalCashier();
        switch (casherEnum) {
            case HALF:
                this.cashier = new RebateCashier(cashier, 0.5);
                break;
            case NORMAL:
                this.cashier = new NormalCashier();
                break;
            case QUARTER:
                this.cashier = new RebateCashier(cashier, 0.25);
                break;
            case BUY_ONE_GET_ONE:
                this.cashier = new RebateCashier(cashier, 0.6);
                this.cashier = new BuyOneGetOneCashier(this.cashier);
                break;
            case REBATE_THEN_RETURN:
                RebateCashier cc = new RebateCashier(cashier, 0.8);
                this.cashier = new ReduceCashier(cc, 300, 100);
        }
    }
    
    public double getMoney(double price, int num) {
        return cashier.check(price, num);
    }
    
}
